import {http} from "@/utils/http";
// import result from "@/router/modules/result";
import type {AxiosRequestConfig} from "axios";

/**
 *  自定义获取剧本列表的接口
 */
// 动态获取 pcToken
const getPcToken = () => {
  return localStorage.getItem("pcToken");
};
const baseProxy = import.meta.env.VITE_BASEPROXY;
interface CustomAxiosRequestConfig extends AxiosRequestConfig {
  id?: number;
}


interface ApiResponse {
  success: boolean;
  data: {
    msg: string;
  };
}

type MsgResponse = {
  msg: string;
};

type ResultTable = {
  success: boolean;
  data?: {
    /** 列表数据 */
    list: Array<any>;
    /** 总条目数 */
    total?: number;
    /** 每页显示条目个数 */
    pageSize?: number;
    /** 当前页数 */
    currentPage?: number;
  };
};

/** 获取剧本管理列表 */
export const getScriptList = (data?: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgScript/queryScriptList`,
    {
      data: data
  }, {
      headers: {
        pcToken: getPcToken()
      }
  });
};

/** 添加剧本 */
export const addScript = (data?: object) => {
  return http.request<any>(
    "post",
    `${baseProxy}/acgScript/createScript`,
    {
      data: data
  }, {
      headers: {
        pcToken: getPcToken()
      }
    }
  );
};

/** 删除剧本 */
export const delScript = (id?: number) => {
  return http.request<any>("post", `${baseProxy}/acgScript/deleteScript`, {
    data: {
      id: id
    },
  }, {
    headers: {
      pcToken: getPcToken()
    }
  });
};


/** 更新剧本 */
export const updateScript = (data?: object) => {
  return http.request<any>("post", `${baseProxy}/acgScript/updateScript`, {
    data: data,
  }, {
    headers: {
      pcToken: getPcToken()
    }
  });
};
